package cn.smart.epic.config;

import cn.smart.epic.config.properties.DruidProperties;
import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import tk.mybatis.spring.annotation.MapperScan;

/**
 * @Auther Uncle_Z
 * @date 2017/9/6 20:20
 * @Email:2545375@qq.com
 * @Descrition
 * @since 1.0
 */

@Configuration
@EnableTransactionManagement(order = 2)
@EnableConfigurationProperties({DruidProperties.class})
@MapperScan(basePackages = {"cn.smart.epic.modular.*.dao","cn.smart.epic.common.persistence.dao"})
public class MybatisPlusConfig {

    private DruidProperties druidProperties;

    public MybatisPlusConfig(DruidProperties druidProperties){
        this.druidProperties = druidProperties;
    }


    @Bean
    public DruidDataSource dataSourceEpic() {
        DruidDataSource druidDataSource = new DruidDataSource();
        druidProperties.config(druidDataSource);
        return druidDataSource;
    }

    /**
     * 数据范围mybatis插件
     * @return
     */
//    @Bean
//    public DataScopeInterceptor dataScopeInterceptor(){
//        return new DataScopeInterceptor();
//    }
}
